package com.example.demo.control;

import com.example.demo.common.CommonResult;
import com.example.demo.pojo.UserGrade;
import com.example.demo.service.UserGradeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "成绩接口")
@RestController
public class GradeControl {

    @Autowired
    private UserGradeService userGradeService;

    @ApiOperation(value = "获得成绩列表")
    @GetMapping("/queryGrade")
    public CommonResult queryGrade(Integer user_id){
        return CommonResult.success(userGradeService.getAll(user_id));
    }

    @ApiOperation(value = "添加成绩")
    @PostMapping("/addGrade")
    public CommonResult addGrade(@RequestBody UserGrade userGrade){
        userGradeService.add(userGrade);
        return CommonResult.success("");
    }

    @ApiOperation(value = "删除成绩")
    @GetMapping("/deleteGrade")
    public CommonResult deleteGrade(Integer id){
        userGradeService.delete(id);
        return CommonResult.success("");
    }


}
